import { HttpStatus } from "@nestjs/common";
import { ApiBadRequestResponse, ApiRequestTimeoutResponse } from "@nestjs/swagger";
import { CrudOptions } from "@nestjsx/crud";
import { PhotoMetadata } from "libs/db/entity/photoMetadata.entity";
import { CreatePhotoMetadataDto } from "./dto/create-photoMetadata-.dto";
import { ReplacePhotoMetadataDto } from "./dto/updata-photoMetadata-.dto";

export const PhotoMetadataCrudOps: CrudOptions = {
  model: {
    type: PhotoMetadata
  },
  query: {
     
    join: {
      photo: {
        eager: true
      }
    },
    exclude:  ["updatedAt", "deleteAt"]
  },
  routes: {
    getManyBase: {
      interceptors: [],
      decorators: [
        
        ApiBadRequestResponse({
          description: '参考相关 DTO 参数说明',
          status: HttpStatus.BAD_REQUEST,
          // schema: BadRequestException
          // schema: HttpErrorByCode(HttpStatus.BADPhotoMetadataREQUEST)
        }),
        ApiRequestTimeoutResponse({
          description: '请求超时',
          status: HttpStatus.REQUEST_TIMEOUT,
        })
      ],
    },
    getOneBase: {
      interceptors: [],
      decorators: [],
    },
    createOneBase: {
      interceptors: [],
      // @UsePipes(ValidationPipe)
      decorators: [],
      returnShallow: true
    },
    createManyBase: {
      interceptors: [],
      decorators: [],
    },
    replaceOneBase: {
      interceptors: [],
      decorators: [],
      allowParamsOverride: true,
      returnShallow: true
    },
    updateOneBase: {
      interceptors: [],
      decorators: [],
      allowParamsOverride: true,
      returnShallow: true
    },
    deleteOneBase: {
      interceptors: [],
      decorators: [],
      returnDeleted: true
    },
  },
  dto: {
    create: CreatePhotoMetadataDto,
    replace: ReplacePhotoMetadataDto
  },
  serialize: {
    getMany: PhotoMetadata,
    get: PhotoMetadata,
    create: PhotoMetadata,
    createMany: PhotoMetadata,
    update: PhotoMetadata,
    replace: PhotoMetadata,
    delete: PhotoMetadata,
  }
}